/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package modelo;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Andre
 */
@Entity
@Table(name = "folha")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Folha.findAll", query = "SELECT f FROM Folha f"),
    @NamedQuery(name = "Folha.findByIdFolha", query = "SELECT f FROM Folha f WHERE f.idFolha = :idFolha"),
    @NamedQuery(name = "Folha.findByReferencia", query = "SELECT f FROM Folha f WHERE f.referencia = :referencia")})
public class Folha implements Serializable {
    
    private static final long serialVersionUID = 1L;
    
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "idFolha")
    private Integer idFolha;
    
    @Basic(optional = false)
    @NotNull
    @Column(name = "referencia")
    @Temporal(TemporalType.TIMESTAMP)
    private Date referencia;
        
    @JoinTable(name = "funcionarioFolha", joinColumns = {
        @JoinColumn(name = "idFolha", referencedColumnName = "idFolha", nullable = false)}, inverseJoinColumns = {
        @JoinColumn(name = "idFuncionario", referencedColumnName = "idPessoa", nullable = false)})
    @ManyToMany
    private List<Funcionario> funcionarios;
    
    @JoinTable(name = "tituloFolha", joinColumns = {
        @JoinColumn(name = "idFolha", referencedColumnName = "idFolha", nullable = false)}, inverseJoinColumns = {
        @JoinColumn(name = "idTitulo", referencedColumnName = "idTitulo", nullable = false),
        @JoinColumn(name = "parcela", referencedColumnName = "parcela", nullable = false)})
    @ManyToMany
    private List<TituloPagar> tituloPagarList;

    public Folha() {
    }

    public Folha(Date referencia) {
        this.referencia = referencia;
    }

    public Integer getIdFolha() {
        return idFolha;
    }

    public Date getReferencia() {
        return referencia;
    }

    public void setReferencia(Date referencia) {
        this.referencia = referencia;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idFolha != null ? idFolha.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Folha)) {
            return false;
        }
        Folha other = (Folha) object;
        if ((this.idFolha == null && other.idFolha != null) || (this.idFolha != null && !this.idFolha.equals(other.idFolha))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "modelo.Folha[ idFolha=" + idFolha + " ]";
    }

    /**
     * @return the funcionarios
     */
    public List<Funcionario> getFuncionarios() {
        return funcionarios;
    }

    /**
     * @param funcionarios the funcionarios to set
     */
    public void setFuncionarios(List<Funcionario> funcionarios) {
        this.funcionarios = funcionarios;
    }

    /**
     * @return the tituloPagarList
     */
    public List<TituloPagar> getTituloPagarList() {
        return tituloPagarList;
    }

    /**
     * @param tituloPagarList the tituloPagarList to set
     */
    public void setTituloPagarList(List<TituloPagar> tituloPagarList) {
        this.tituloPagarList = tituloPagarList;
    }
    
}
